package sumo.box;



import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;



public class Level2 extends Level {
    Image ovelha = null;
    public Level2(int id){
        super(id,8);
    }
    @Override
    public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
        super.init(gc, sbg);
        ovelha = new Image("src/IMAGES/sheep.png");
        /*********************** LOCAL DAS BOMBAS?? **************************/
        hero = new Personagem(280, 120);
        
        bombs[0] = new Bomba(160, 240, false);
        bombs[1] = new Bomba(80, 200, true);
        bombs[2] = new Bomba(120, 200, true);
        bombs[3] = new Bomba(160, 200, true);
        bombs[4] = new Bomba(200, 200, true);
        bombs[5] = new Bomba(240, 200, true);
        bombs[6] = new Bomba(280, 200, true);
        bombs[7] = new Bomba(320, 200, true);


 
        places[0] = new Lugar(40, 200, false);
        places[1] = new Lugar(80, 200, true);
        places[2] = new Lugar(120, 200, true);
        places[3] = new Lugar(160, 200, true);
        places[4] = new Lugar(200, 200, true);
        places[5] = new Lugar(240, 200, true);
        places[6] = new Lugar(280, 200, true);
        places[7] = new Lugar(320, 200, true);
        /*********************************************************************/
    }
    @Override
    public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
        super.render(gc, sbg, g);
        if(timer%14 < 7){
            ovelha = new Image("src/IMAGES/sheep2.png");
            ovelha.draw(243+(timer%14),330, 0.8f);
        } else {
            ovelha = new Image("src/IMAGES/sheep.png");
            ovelha.draw(257-(timer%14),330, 0.8f);
        }
    }
    
    @Override
    public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException {
        
        timer += 0.002;
        if (CompleteTest.test(places, numero) == true){
            Box.completeSoundInterrupt();
            Box.sheepSound();
            Highscores.setScore(this.ident, hero.getMovs());
            gc.reinit();
            sbg.enterState(Box.LEVELSELECTSTATE);
        }
        super.update(gc, sbg, i);
        
    }
}
